﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using WhittleList.Bll;
using WhittleList.Tests.Helpers;
using WhittleList.Tests.Mocks;

namespace WhittleList.Tests.Bll
{
    [TestClass]
    public class SiteTests
    {
        [TestMethod]
        public void Site_IdSignatureTest()
        {
            var prop = typeof(Site).GetProperty("Id");
            Assert.IsNotNull(prop);
            prop.AssertReadyOnly();
            prop.AssertInt();
        }

        [TestMethod]
        public void Site_NameSignatureTest()
        {
            var prop = typeof(Site).GetProperty("Name");
            Assert.IsNotNull(prop);
            prop.AssertReadyWrite();
            prop.AssertString();
        }

        [TestMethod]
        public void Site_UrlSignatureTest()
        {
            var prop = typeof(Site).GetProperty("Url");
            Assert.IsNotNull(prop);
            prop.AssertReadyWrite();
            prop.AssertString();
        }

        [TestMethod]
        public void Site_OwnerIdSignatureTest()
        {
            var prop = typeof(Site).GetProperty("OwnerId");
            Assert.IsNotNull(prop);
            prop.AssertReadyWrite();
            prop.AssertInt();
        }

        [TestMethod]
        public void Site_CIDSignatureTest()
        {
            var prop = typeof(Site).GetProperty("CID");
            prop.AssertReadyOnly();
            prop.AssertBinary();
        }


        [TestMethod]
        public void Site_IsValidSignatureTest()
        {
            var prop = typeof(Site).GetProperty("IsValid");
            prop.AssertReadyOnly();
            prop.AssertBool();
        }

        [TestMethod]
        public void Site_CreatedByIdSignatureTest()
        {
            var prop = typeof(Site).GetProperty("CreatedById");
            prop.AssertReadyOnly();
            prop.AssertInt();
        }

        [TestMethod]
        public void Site_CreatedSignatureTest()
        {
            var prop = typeof(Site).GetProperty("Created");
            prop.AssertReadyOnly();
            prop.AssertDateTime();
        }

        [TestMethod]
        public void Site_LastUpdatedByIdSignatureTest()
        {
            var prop = typeof(Site).GetProperty("LastUpdatedById");
            prop.AssertReadyOnly();
            prop.AssertInt();
        }
        
        [TestMethod]
        public void Site_LastUpdatedSignatureTest()
        {
            var prop = typeof(Site).GetProperty("LastUpdated");
            prop.AssertReadyOnly();
            prop.AssertDateTime();
        }


        [TestMethod]
        public void Site_Name_Required()
        {
            var site = new Site();
            Assert.AreEqual(1, site.GetRuleViolations().Where(x => x.PropertyName == "Name").Count());
            site.Name = "Test";
            Assert.AreEqual(0, site.GetRuleViolations().Where(x => x.PropertyName == "Name").Count());
        }

        [TestMethod]
        public void Site_Url_Required()
        {
            var site = new Site();
            Assert.AreEqual(1, site.GetRuleViolations().Where(x => x.PropertyName == "Url").Count());
            site.Url = "Test";
            Assert.AreEqual(0, site.GetRuleViolations().Where(x => x.PropertyName == "Url").Count());
        }
    }
}
